package com.kotlin.mvpdemo.entity;

import retrofit2.Response;

/**
 * author : fang.zhang
 * e-mail : initzf@126.com
 * date   : 2020/6/6
 * desc   :
 */
public class ApiResponse<T> {

    public static final int ERROR_CODE = 99999;

    public int code;
    private T body;
    public String msg;

    public ApiResponse(Response<T> response) {
        setBody(response.body());
    }

    public ApiResponse(BaseEntity<T> body) {
        setBody(null);
        this.code = body.getErrorCode();
        this.msg = body.getErrorMsg();
    }


    public ApiResponse(Throwable t) {
        setBody(null);
        code = ERROR_CODE;
    }


    public T getBody() {
        return body;
    }

    public void setBody(T body) {
        this.body = body;
    }
}

